package com.ssy.lingxi.order.handler.validator;

import com.ssy.lingxi.common.constant.order.OrderPayTypeEnum;
import com.ssy.lingxi.order.handler.annotation.DeliveryTypeAnnotation;
import com.ssy.lingxi.order.handler.annotation.OrderPayTypeAnnotation;
import com.ssy.lingxi.order.model.constant.OrderProductDeliverTypeEnum;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;

/**
 * 订单支付方式校验注解验证类
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-15
 */
public class OrderPayTypeValidator implements ConstraintValidator<OrderPayTypeAnnotation, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if(value == null) {
            return false;
        }

        return Arrays.stream(OrderPayTypeEnum.values()).anyMatch(e -> e.getCode().equals(value));
    }
}
